/**
 * 
 */
package net.xfok.string.filter;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author howard
 *
 */
public class Regex {
	
	public final static String REG_HTML = "<([^>]*)\\s*>";
	public final static String REG_LINK = "<a\\s+([^>]*)\\s*>";
	public final static String REG_EMAIL = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
	public final static String REG_IMG = "<img\\s+([^>]*)\\s*>";
	public final static String REG_DIV = "<div+([^>]*)\\s*>";
	public final static String REG_URL = "(/)+[^\"]*";
	public final static String REG_AB_URL = "[\\w]+://[^\"]*";
	
	public static List<String> genStrByReg(String str,String regStr) {
		List<String> list = new ArrayList<String>();
		StringBuffer sb = new StringBuffer(str);
		Pattern ptn = Pattern.compile(regStr, Pattern.CASE_INSENSITIVE);
		Matcher matcher = ptn.matcher(sb);
		while (matcher.find()) {
			int start = matcher.start();
			int end = matcher.end();
			list.add(sb.substring(start, end));
		}
		return list;
	}
}
